nethackfandomcom-20200214-history
Source:Tradstdc.h
Below is the full text to include/tradstdc.h from NetHack 3.4.3. To link to a particular line, write [[tradstdc.h#line123]], for example. 1. /* SCCS Id: @(#)tradstdc.h 3.4 1993/05/30 */ 2. /* Copyright © Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /* NetHack may be freely redistributed. See license for details. */ 4. 5. #ifndef TRADSTDC_H 6. #define TRADSTDC_H 7. 8. #if defined(DUMB) && !defined(NOVOID) 9. #define NOVOID 10. #endif 11. 12. #ifdef NOVOID 13. #define void int 14. #endif 15. 16. /* 17. * Borland C provides enough ANSI C compatibility in its Borland C++ 18. * mode to warrant this. But it does not set __STDC__ unless it compiles 19. * in its ANSI keywords only mode, which prevents use of and 20. * far pointer use. 21. */ 22. #if (defined(__STDC__) || defined(__TURBOC__)) && !defined(NOTSTDC) 23. #define NHSTDC 24. #endif 25. 26. #if defined(ultrix) && defined(__STDC__) && !defined(__LANGUAGE_C) 27. /* Ultrix seems to be in a constant state of flux. This check attempts to 28. * set up ansi compatibility if it wasn't set up correctly by the compiler. 29. */ 30. #ifdef mips 31. #define __mips mips 32. #endif 33. 34. #ifdef LANGUAGE_C 35. #define __LANGUAGE_C LANGUAGE_C 36. #endif 37. 38. #endif 39. 40. /* 41. * ANSI X3J11 detection. 42. * Makes substitutes for compatibility with the old C standard. 43. */ 44. 45. /* Decide how to handle variable parameter lists: 46. * USE_STDARG means use the ANSI facilities (only ANSI compilers 47. * should do this, and only if the library supports it). 48. * USE_VARARGS means use the facilities. Again, this should only 49. * be done if the library supports it. ANSI is *not* required for this. 50. * Otherwise, the kludgy old methods are used. 51. * The defaults are USE_STDARG for ANSI compilers, and USE_OLDARGS for 52. * others. 53. */ 54. 55. /* #define USE_VARARGS */ /* use instead of */ 56. /* #define USE_OLDARGS */ /* don't use any variable argument facilites */ 57. 58. #if defined(apollo) /* Apollos have stdarg(3) but not stdarg.h */ 59. # define USE_VARARGS 60. #endif 61. 62. #if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(MAC) 63. # if !defined(USE_VARARGS) && !defined(USE_OLDARGS) && !defined(USE_STDARG) 64. # define USE_STDARG 65. # endif 66. #endif 67. 68. #ifdef NEED_VARARGS /* only define these if necessary */ 69. #ifdef USE_STDARG 70. #include 71. # define VA_DECL(typ1,var1) (typ1 var1, ...) { va_list the_args; 72. # define VA_DECL2(typ1,var1,typ2,var2) \ 73. (typ1 var1, typ2 var2, ...) { va_list the_args; 74. # define VA_INIT(var1,typ1) 75. # define VA_NEXT(var1,typ1) var1 = va_arg(the_args, typ1) 76. # define VA_ARGS the_args 77. # define VA_START(x) va_start(the_args, x) 78. # define VA_END() va_end(the_args) 79. # if defined(ULTRIX_PROTO) && !defined(_VA_LIST_) 80. # define _VA_LIST_ /* prevents multiple def in stdio.h */ 81. # endif 82. #else 83. # ifdef USE_VARARGS 84. #include 85. # define VA_DECL(typ1,var1) (va_alist) va_dcl {\ 86. va_list the_args; typ1 var1; 87. # define VA_DECL2(typ1,var1,typ2,var2) (va_alist) va_dcl {\ 88. va_list the_args; typ1 var1; typ2 var2; 89. # define VA_ARGS the_args 90. # define VA_START(x) va_start(the_args) 91. # define VA_INIT(var1,typ1) var1 = va_arg(the_args, typ1) 92. # define VA_NEXT(var1,typ1) var1 = va_arg(the_args,typ1) 93. # define VA_END() va_end(the_args) 94. # else 95. # define VA_ARGS arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9 96. # define VA_DECL(typ1,var1) (var1,VA_ARGS) typ1 var1; \ 97. char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; { 98. # define VA_DECL2(typ1,var1,typ2,var2) (var1,var2,VA_ARGS) \ 99. typ1 var1; typ2 var2;\ 100. char *arg1,*arg2,*arg3,*arg4,*arg5,*arg6,*arg7,*arg8,*arg9; { 101. # define VA_START(x) 102. # define VA_INIT(var1,typ1) 103. # define VA_END() 104. # endif 105. #endif 106. #endif /* NEED_VARARGS */ 107. 108. #if defined(NHSTDC) || defined(MSDOS) || defined(MAC) || defined(ULTRIX_PROTO) || defined(__BEOS__) 109. 110. /* 111. * Used for robust ANSI parameter forward declarations: 112. * int VDECL(sprintf, (char *, const char *, ...)); 113. * 114. * NDECL() is used for functions with zero arguments; 115. * FDECL() is used for functions with a fixed number of arguments; 116. * VDECL() is used for functions with a variable number of arguments. 117. * Separate macros are needed because ANSI will mix old-style declarations 118. * with prototypes, except in the case of varargs, and the OVERLAY-specific 119. * trampoli.* mechanism conflicts with the ANSI <> syntax. 120. */ 121. 122. # define NDECL(f) f(void) /* overridden later if USE_TRAMPOLI set */ 123. 124. # define FDECL(f,p) f p 125. 126. # if defined(MSDOS) || defined(USE_STDARG) 127. # define VDECL(f,p) f p 128. # else 129. # define VDECL(f,p) f() 130. # endif 131. 132. /* generic pointer, always a macro; genericptr_t is usually a typedef */ 133. # define genericptr void * 134. 135. # if (defined(ULTRIX_PROTO) && !defined(__GNUC__)) || defined(OS2_CSET2) 136. /* Cover for Ultrix on a DECstation with 2.0 compiler, which coredumps on 137. * typedef void * genericptr_t; 138. * extern void a(void(*)(int, genericptr_t)); 139. * Using the #define is OK for other compiler versions too. 140. */ 141. /* And IBM CSet/2. The redeclaration of free hoses the compile. */ 142. # define genericptr_t genericptr 143. # else 144. # if !defined(NHSTDC) && !defined(MAC) 145. # define const 146. # define signed 147. # define volatile 148. # endif 149. # endif 150. 151. /* 152. * Suppress `const' if necessary and not handled elsewhere. 153. * Don't use `#if defined(xxx) && !defined(const)' 154. * because some compilers choke on `defined(const)'. 155. * This has been observed with Lattice, MPW, and High C. 156. */ 157. # if (defined(ULTRIX_PROTO) && !defined(NHSTDC)) || defined(apollo) 158. /* the system header files don't use `const' properly */ 159. # ifndef const 160. # define const 161. # endif 162. # endif 163. 164. #else /* NHSTDC */ /* a "traditional" C compiler */ 165. 166. # define NDECL(f) f() 167. # define FDECL(f,p) f() 168. # define VDECL(f,p) f() 169. 170. # if defined(AMIGA) || defined(HPUX) || defined(POSIX_TYPES) || defined(__DECC) || defined(__BORLANDC__) 171. # define genericptr void * 172. # endif 173. # ifndef genericptr 174. # define genericptr char * 175. # endif 176. 177. /* 178. * Traditional C compilers don't have "signed", "const", or "volatile". 179. */ 180. # define signed 181. # define const 182. # define volatile 183. 184. #endif /* NHSTDC */ 185. 186. 187. #ifndef genericptr_t 188. typedef genericptr genericptr_t; /* (void *) or (char *) */ 189. #endif 190. 191. 192. /* 193. * According to ANSI, prototypes for old-style declarations must widen the 194. * arguments to int. However, the MSDOS compilers accept shorter arguments 195. * (char, short, etc.) in prototypes and do typechecking with them. Therefore 196. * this mess to allow the better typechecking while also allowing some 197. * prototypes for the ANSI compilers so people quit trying to fix the 198. * prototypes to match the standard and thus lose the typechecking. 199. */ 200. #if defined(MSDOS) && !defined(__GO32__) 201. #define UNWIDENED_PROTOTYPES 202. #endif 203. #if defined(AMIGA) && !defined(AZTEC_50) 204. #define UNWIDENED_PROTOTYPES 205. #endif 206. #if defined(macintosh) && (defined(__SC__) || defined(__MRC__)) 207. #define WIDENED_PROTOTYPES 208. #endif 209. #if defined(__MWERKS__) && defined(__BEOS__) 210. #define UNWIDENED_PROTOTYPES 211. #endif 212. #if defined(WIN32) 213. #define UNWIDENED_PROTOTYPES 214. #endif 215. 216. #if defined(ULTRIX_PROTO) && defined(ULTRIX_CC20) 217. #define UNWIDENED_PROTOTYPES 218. #endif 219. #if defined(apollo) 220. #define UNWIDENED_PROTOTYPES 221. #endif 222. 223. #ifndef UNWIDENED_PROTOTYPES 224. # if defined(NHSTDC) || defined(ULTRIX_PROTO) || defined(THINK_C) 225. # define WIDENED_PROTOTYPES 226. # endif 227. #endif 228. 229. #if 0 230. /* The problem below is still the case through 4.0.5F, but the suggested 231. * compiler flags in the Makefiles suppress the nasty messages, so we don't 232. * need to be quite so drastic. 233. */ 234. #if defined(__sgi) && !defined(__GNUC__) 235. /* 236. * As of IRIX 4.0.1, /bin/cc claims to be an ANSI compiler, but it thinks 237. * it's impossible for a prototype to match an old-style definition with 238. * unwidened argument types. Thus, we have to turn off all NetHack 239. * prototypes, and avoid declaring several system functions, since the system 240. * include files have prototypes and the compiler also complains that 241. * prototyped and unprototyped declarations don't match. 242. */ 243. # undef NDECL 244. # undef FDECL 245. # undef VDECL 246. # define NDECL(f) f() 247. # define FDECL(f,p) f() 248. # define VDECL(f,p) f() 249. #endif 250. #endif 251. 252. 253. /* MetaWare High-C defaults to unsigned chars */ 254. /* AIX 3.2 needs this also */ 255. #if defined(__HC__) || defined(_AIX32) 256. # undef signed 257. #endif 258. 259. 260. /* 261. * Allow gcc2 to check parameters of printf-like calls with -Wformat; 262. * append this to a prototype declaration (see pline() in extern.h). 263. */ 264. #ifdef __GNUC__ 265. # if __GNUC__ >= 2 266. #define PRINTF_F(f,v) __attribute__ ((format (printf, f, v))) 267. # endif 268. #endif 269. #ifndef PRINTF_F 270. #define PRINTF_F(f,v) 271. #endif 272. 273. #endif /* TRADSTDC_H */ Category:source code